package com.example.testnews.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

import com.example.testnews.R;

public class NewsActivity extends AppCompatActivity {

    private static final String TAG = "NewsActivity";
    private WebView webView;
    private String url1;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);
        webView = findViewById(R.id.news_webview);
        Intent intent = getIntent();
        url1 = intent.getStringExtra("extra_data");




        webView.setWebViewClient(new WebViewClient());// 设置WebView的客户端
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);// 让WebView能够执行javaScript
        webSettings.setSupportZoom(true);// 支持缩放(适配到当前屏幕)
        webSettings.setUseWideViewPort(true); // 将图片调整到合适的大小
        //webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
        webSettings.setDisplayZoomControls(true);// 设置可以被显示的屏幕控制
        webSettings.setDefaultFontSize(12); // 设置默认字体大小
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);//设置 缓存模式
        webSettings.setDomStorageEnabled(true);// 开启 DOM storage API 功能
        Log.e(TAG,"+++++++++++++++++++++++"+url1);
        webView.loadUrl(url1.replace("http","https"));




//        String data = intent.getStringExtra("extra_data");
//        Log.i(TAG, "onCreate: " + data);
    }


}